using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;	   

namespace Possan.Graphics.Filters
{						  
	public class Grayscale : IBaseFilter 
	{
		public string ParameterDefinition
		{
			get
			{
				     return null;
			}
		}
	    
		public Bitmap Filter(Bitmap bitmap)
		{
			Bitmap neu = bitmap.Clone() as Bitmap;

			for (int j = 0; j < neu.Height ;  j++)
			{
				for (int i = 0; i < neu.Width ;  i++)
				{
					Color c = neu.GetPixel(i, j);
					float bri = c.GetBrightness() * 255.0f;					
					int ibri = Math.Max(Math.Min((int)bri, 255), 0);
					Color c2 = Color.FromArgb(c.A, ibri, ibri, ibri);
					neu.SetPixel(i, j, c2);
				}
			}

			     return neu;
		}
	}
}





